

<template>
<div>
     <!-- <Button type="primary" @click="modal1 = true">Display dialog box</Button> -->
     <Modal v-model="mode" width="80%"  title="红枣出库-结算" @change="testChange"  @on-cancel="cancel">
          <Form ref="DlvOrderData"  :model="DlvOrderData"  :rules="ruleInUser" :label-width="100">
                <div style="width:100%;height:auto;margin:0 auto;">
                  <Row type="flex" justify="center">
                    <i-col span="12">
                      <FormItem label="订单编号：" prop="Id">
                        <Input v-model="DlvOrderData.OrderNo" class="orders_disabled" placeholder="请输入用户编号" disabled />
                      </FormItem>

                      <FormItem label="客户名称：" prop="ClassName">
                        <Input v-model="DlvOrderData.CustomerName" class="orders_disabled_custom" placeholder="请输入客户名称"  disabled/>
                      </FormItem> 
                     </i-col>
                     <i-col span="12"></i-col>
                  </Row>

                  <Row type="flex" justify="center">
                    <i-col span="4"> 
                      <FormItem label="出库商品1：" prop="GoodsNameFst" v-if="DlvOrderData.GoodsNameFst != ''">
                          <Input v-model="DlvOrderData.GoodsNameFst" class="orders_disabled_custom" placeholder="请输入商品名称"  disabled/>
                      </FormItem> 

                      <FormItem label="出库商品2：" prop="GoodsNameSec" v-if="DlvOrderData.GoodsNameSec != ''">
                          <Input v-model="DlvOrderData.GoodsNameSec" class="orders_disabled_custom" placeholder="请输入商品名称"  disabled/>
                      </FormItem> 

                      <FormItem label="出库商品3：" prop="GoodsNameThd" v-if="DlvOrderData.GoodsNameThd != ''">
                          <Input v-model="DlvOrderData.GoodsNameThd" class="orders_disabled_custom" placeholder="请输入商品名称"  disabled/>
                      </FormItem> 

                      <FormItem label="服务费用：" prop="StoreFee">
                          <InputNumber v-model="DlvOrderData.StoreFee" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 
                      
                      <FormItem label="合计费用：" prop="SumMoney">
                          <InputNumber v-model="DlvOrderData.SumFee" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem>                  
                    </i-col>
                  
                    <i-col span="4">
                      <FormItem label="出库件数：" prop="GoodsFstDlvCount" v-if="DlvOrderData.GoodsNameFst != ''">
                          <InputNumber v-model="DlvOrderData.GoodsFstDlvCount" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="出库件数：" prop="GoodsSecDlvCount" v-if="DlvOrderData.GoodsNameSec != ''">
                          <InputNumber v-model="DlvOrderData.GoodsSecDlvCount" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="出库件数：" prop="GoodsThdDlvCount" v-if="DlvOrderData.GoodsNameThd != ''">
                          <InputNumber v-model="DlvOrderData.GoodsThdDlvCount" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="冷藏费用：" prop="ColdFee">
                          <InputNumber v-model="DlvOrderData.ColdFee" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 
                    </i-col>

                    <i-col span="4">
                      <FormItem label="出库重量：" prop="GoodsFstDlvWeight" v-if="DlvOrderData.GoodsNameFst != ''">
                          <InputNumber v-model="DlvOrderData.GoodsFstDlvWeight" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="出库重量：" prop="GoodsSecDlvWeight" v-if="DlvOrderData.GoodsNameSec != ''">
                          <InputNumber v-model="DlvOrderData.GoodsSecDlvWeight" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="出库重量：" prop="GoodsThdDlvWeight" v-if="DlvOrderData.GoodsNameThd != ''">
                          <InputNumber v-model="DlvOrderData.GoodsThdDlvWeight" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="入库装卸费：" prop="StoreUnloadFee">
                          <InputNumber v-model="DlvOrderData.StoreUnloadFee" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 
                    </i-col>

                    <i-col span="4">
                      <FormItem label="单价：" prop="GoodsFstPrice" v-if="DlvOrderData.GoodsNameFst != ''">
                          <InputNumber v-model="DlvOrderData.GoodsFstPrice" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="单价：" prop="GoodsSecPrice" v-if="DlvOrderData.GoodsNameSec != ''">
                          <InputNumber v-model="DlvOrderData.GoodsSecPrice" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="单价：" prop="GoodsThdPrice" v-if="DlvOrderData.GoodsNameThd != ''">
                          <InputNumber v-model="DlvOrderData.GoodsThdPrice" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="出库装卸费：" prop="DlvLoadFee">
                          <InputNumber v-model="DlvOrderData.DlvLoadFee" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem>                
                    </i-col>

                    <i-col span="4">
                      <FormItem label="出库金额：" prop="GoodsFstDlvMoney" v-if="DlvOrderData.GoodsNameFst != ''">
                          <InputNumber v-model="DlvOrderData.GoodsFstDlvMoney" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="出库金额：" prop="GoodsSecDlvMoney" v-if="DlvOrderData.GoodsNameSec != ''">
                          <InputNumber v-model="DlvOrderData.GoodsSecDlvMoney" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="出库金额：" prop="GoodsThdDlvMoney" v-if="DlvOrderData.GoodsNameThd != ''">
                          <InputNumber v-model="DlvOrderData.GoodsThdDlvMoney" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 
                    </i-col>

                    <i-col span="4">
                      <FormItem label="利息：" prop="InterestFst" v-if="DlvOrderData.GoodsNameFst != ''">
                          <InputNumber v-model="DlvOrderData.InterestFst" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="利息：" prop="InterestSec" v-if="DlvOrderData.GoodsNameSec != ''">
                          <InputNumber v-model="DlvOrderData.InterestSec" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 

                      <FormItem label="利息：" prop="InterestThd" v-if="DlvOrderData.GoodsNameThd != ''">
                          <InputNumber v-model="DlvOrderData.InterestThd" class="orders_disabled" placeholder="请输入质押件数" disabled/>
                      </FormItem> 
                    </i-col>
                  </Row>

                  <Row>            
                    <i-col span="20">
                        <FormItem>
                            <Button type="primary" :loading="loading" class="buttn_rough"  @click="handleSubmit('DlvOrderData',2)">结算</Button>
                            <!--
                            <Button type="warning" :loading="loading" class="buttn_skin" @click="handleSubmit('DlvOrderData')">称皮重</Button>
                             <Button @click="handleReset('formValidate')" style="margin-left: 8px">重置</Button> -->
                         </FormItem>
                   </i-col>
                  </Row>

                </div>
              </Form>


        <div slot="footer" >
            <!-- <Button type="error" size="large" long :loading="modal_loading" @click="del">Delete</Button> -->
        </div>
    </Modal>
</div>
</template>

<script>
import {getCompanyList,getDeptList,updateDlvOrderData,timestampToDate} from "@/api/data";
import { formatDate } from '../../components/date.js';
import { getToken } from "@/libs/util";
export default {
    name: 'Edit',
    data () {
        return {
          loading:false,
          mode:this.edit,
          
          //表单验证规则
          ruleInUser: {


          },

           TypeClassList:[
            {
              Id:1,
              TypeClassName:'灰枣一级'
            },
            {
              Id:2,
              TypeClassName:'骏枣一级'
            }
          ],

          LandingPlaceList:[
            {
              Id:1,
              LandingPlaceName:'场地1'
            },
            {
              Id:2,
              LandingPlaceName:'场地2'
            }
          ],

           PackList:[
            {
              Id:1,
              PackName:'箱装'
            },
            {
              Id:2,
              PackName:'框装'
            }
          ],
         
          listdata:[]

        };
    },
    props:{
        edit:{
            type:Boolean ,
            required:true
        },
        DlvOrderData:{
            type:Object,
            required:true 
        },
        


    },
    methods: {
      testChange(val){
        this.$emit('testChange',val);
       },
      cancel(){
           this.loading = false; 
          let data = {
            mode:false
          }
          this.$emit('cancelCallBack', data);
       },
      //提交编辑后的userInfo
      handleSubmit(name,status) {
        
        this.$refs[name].validate(valid => { 
          console.log("提交验证：",valid)    
          if (valid) {  
            this.loading = true;      
            this.submit(status);
          } else {
            this.$Message.error("请填写相关信息!");
          }
        });
      },
    submit(status){
        var accountPerson = getToken() 
        var accountTime = timestampToDate(new Date(),'yyyy-MM-dd HH:mm:ss')
        const data = {
            Id:this.DlvOrderData.Id,
            AccountPerson:accountPerson,
            AccountTime:accountTime,
            Status:status
    };
      updateDlvOrderData(data).then(res =>{
            if(res == "OK"){
              this.$Message.success("提交成功");
              this.loading = false; 
              let data = {
                mode:false
              }
              this.$emit('success', data);   
            }else if(response.data.flag == 0){
            this.$Message.success("提交失败"); 
            }else if(response.data.flag == 2){
            this.$Message.success("状态过期");
            }
        }).catch(error => {
            this.$Message.error("请核对之后重新提交1");
             this.loading = false; 
       });


     },
    },
    mounted () {
      const cmpdata = {
        fields:"Id,CompanyName",
        offset:"0",
        limit:"-1"
      };
      const dptdata = {
        fields:"Id,DeptName",
        offset:"0",
        limit:"-1"
      };
      //获得包含公司Id和companyname字段的全部列表
      // getCompanyList(cmpdata).then(res =>{
      //   this.CompanyList = res.List;
        
      // });
      //获得包含公司Id和companyname字段的全部列表
      // getDeptList(dptdata).then(res =>{
      //   this.DeptList = res.List;
      // });
    },
    watch: {
        edit(val) {
        this.mode = val
    }
}
}
</script>
<style>
.dept .ivu-select-placeholder{
color:#515a6e!important;
}

.orders_disabled_custom input{
    border:none;
    background-color:#fff!important;
    color:gray!important;
    width: 280px;
}

.buttn_rough{
  width: 100px;
}

.buttn_skin{
  width: 100px;
  margin-left: 150px;
}
</style>